import { createApp } from 'vue'
import './style.css'
import App from './App.vue'
import router from './router'
import piniaPluginPersist from 'pinia-plugin-persistedstate';
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import {createPinia} from 'pinia'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
const pinia = createPinia()
pinia.use(piniaPluginPersist);
let app = createApp(App)
app.config.globalProperties.formatDate = function(date:Date) {
  if(!date) return ""
  date = new Date(date);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');

  return `${year}-${month}-${day}`;
}
app.config.globalProperties.$icons=[]
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
	app.config.globalProperties.$icons.push(key)
    app.component(key, component)
  }
app.use(ElementPlus)
app.use(router)
app.use(pinia)


app.mount('#app')
